$(function () {

    $('form').on('submit', async e => {
        e.preventDefault()
        if (!$('.username').val() || !$('.password').val() || !$('.rpassword').val() || !$('.nickname').val()) return alert('请完整填写信息')
        if ($('.password').val() !== $('.rpassword').val()) return alert('两次书写密码需要相同')
        const res = await $.ajax({
            url: '/users/register',
            data: $('form').serialize(),
            method: 'post'
        })
        console.log(res);
        window.location.href = '/pages/login'
    })
})